﻿using System;

namespace iOSClub.App.Desktop.ViewModels.ToolPages;

public static class StringGlyph
{
    public static string Glyph(this string codepoint)
        => char.ConvertFromUtf32((int)Convert.ToUInt32(codepoint, 16));
}

public record PageRecord(string PageName, string Glyph, string PageTag, string Description);

public class HomeViewModel : ViewModelBase
{
    public PageRecord[] SoftPageRecords =>
    [
        new PageRecord("Base64图像解析", "F807F".Glyph(), "Base64Image", "Base64图像解析"),
        new PageRecord("Base64文本编码/解码", "\uE148", "Base64String", "Base64文本编码/解码"),
        new PageRecord("Html编码转换", "F8134".Glyph(), "HtmlConverter", "将Htm进行编码解码处理"),
        new PageRecord("GZip压缩解码", "\uF012", "GZipEncode", "使用GZip进行对文本的压缩"),
        new PageRecord("翻译", "\uE164", "Translate", "调用翻译Api生成翻译结果"),
        new PageRecord("进制转换", "#", "BaseConverter", "进制间转换，目前支持二、八、十、十六进制转换"),
        new PageRecord("哈希值生成工具", "Hash", "HashGenerate", "根据算法的不同生成对应的哈希值"),
    ];
}

public class ConverterViewModel : ViewModelBase
{
    public PageRecord[] SoftPageRecords =>
    [
        new PageRecord("正则表达式", "\uE16C", "RegexConverter", "使用正则表达式对文本进行匹配"),
        new PageRecord("翻译", "\uE164", "Translate", "调用翻译Api生成翻译结果"),
        new PageRecord("进制转换", "#", "BaseConverter", "进制间转换，目前支持二、八、十、十六进制转换")
    ];
}

public class EncodeViewModel : ViewModelBase
{
    public PageRecord[] SoftPageRecords =>
    [
        new PageRecord("Base64图像解析", "F807F".Glyph(), "Base64Image", "Base64图像解析"),
        new PageRecord("Base64文本编码/解码", "\uE148", "Base64String", "Base64文本编码/解码"),
        new PageRecord("Html编码转换", "F8134".Glyph(), "HtmlConverter", "将Htm进行编码解码处理"),
        new PageRecord("GZip压缩解码", "\uF012", "GZipEncode", "使用GZip进行对文本的压缩"),
    ];
}

public class GenerateViewModel : ViewModelBase
{
    public PageRecord[] SoftPageRecords =>
    [
        new PageRecord("哈希值生成工具", "Hash", "HashGenerate", "根据算法的不同生成对应的哈希值"),
    ];
}